<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Time</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Time' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../extensions.html">Kits</a></li><li><a href="index.html">WorldModelKit</a></li><li><b>Time</b></li></ul></div>
<p class="purpose">Time  Support for parsing and printing times of day.</p>

<ul class="toc"><li><a href="tm.html#SP1">&#167;1. Conversion To Number</a></li><li><a href="tm.html#SP2">&#167;2. Digital Printing</a></li><li><a href="tm.html#SP3">&#167;3. Analogue Printing</a></li><li><a href="tm.html#SP4">&#167;4. Understanding</a></li><li><a href="tm.html#SP5">&#167;5. Relative Time Token</a></li><li><a href="tm.html#SP6">&#167;6. Scene Change Machinery Rule</a></li><li><a href="tm.html#SP7">&#167;7. During Scene Matching</a></li><li><a href="tm.html#SP8">&#167;8. Scene Questions</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Conversion To Number.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">NUMBER_TY_to_TIME_TY</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">CongruenceClass</span><span class="plain-syntax">(</span><span class="identifier-syntax">n</span><span class="plain-syntax">, </span><span class="constant-syntax">1440</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Digital Printing.</b>For instance, "2:06 am".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PrintTimeOfDay</span><span class="plain-syntax"> </span><span class="identifier-syntax">t</span><span class="plain-syntax"> </span><span class="identifier-syntax">h</span><span class="plain-syntax"> </span><span class="identifier-syntax">aop</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax">&lt;0) { </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"&lt;no time&gt;"</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">TWELVE_HOURS</span><span class="plain-syntax">) { </span><span class="identifier-syntax">aop</span><span class="plain-syntax"> = </span><span class="string-syntax">"pm"</span><span class="plain-syntax">; </span><span class="identifier-syntax">t</span><span class="plain-syntax"> = </span><span class="identifier-syntax">t</span><span class="plain-syntax"> - </span><span class="identifier-syntax">TWELVE_HOURS</span><span class="plain-syntax">; } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">aop</span><span class="plain-syntax"> = </span><span class="string-syntax">"am"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">h</span><span class="plain-syntax"> = </span><span class="identifier-syntax">t</span><span class="plain-syntax">/</span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">h</span><span class="plain-syntax">==0) </span><span class="identifier-syntax">h</span><span class="plain-syntax">=12;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="identifier-syntax">h</span><span class="plain-syntax">, </span><span class="string-syntax">":"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax">%</span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">10</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"0"</span><span class="plain-syntax">; </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="identifier-syntax">t</span><span class="plain-syntax">%</span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">, </span><span class="string-syntax">" "</span><span class="plain-syntax">, (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">aop</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">PrintDuration</span><span class="plain-syntax"> </span><span class="identifier-syntax">t</span><span class="plain-syntax"> </span><span class="identifier-syntax">h</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax">&lt;0) { </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"minus "</span><span class="plain-syntax">; </span><span class="identifier-syntax">t</span><span class="plain-syntax"> = -</span><span class="identifier-syntax">t</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">h</span><span class="plain-syntax"> = </span><span class="identifier-syntax">t</span><span class="plain-syntax">/</span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">; </span><span class="identifier-syntax">m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">t</span><span class="plain-syntax">%</span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">h</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="identifier-syntax">h</span><span class="plain-syntax">, </span><span class="string-syntax">" hour"</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">h</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"s"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">h</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">m</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"1 minute"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">h</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">m</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax">, </span><span class="string-syntax">" minutes"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Analogue Printing.</b>For instance, "six minutes past two".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">PrintTimeOfDayEnglish</span><span class="plain-syntax"> </span><span class="identifier-syntax">t</span><span class="plain-syntax"> </span><span class="identifier-syntax">h</span><span class="plain-syntax"> </span><span class="identifier-syntax">m</span><span class="plain-syntax"> </span><span class="identifier-syntax">dir</span><span class="plain-syntax"> </span><span class="identifier-syntax">aop</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">h</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">t</span><span class="plain-syntax">/</span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">) % </span><span class="constant-syntax">12</span><span class="plain-syntax">; </span><span class="identifier-syntax">m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">t</span><span class="plain-syntax">%</span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">h</span><span class="plain-syntax">==0) </span><span class="identifier-syntax">h</span><span class="plain-syntax">=12;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">m</span><span class="plain-syntax">==0) { </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">h</span><span class="plain-syntax">, </span><span class="string-syntax">" o'clock"</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">dir</span><span class="plain-syntax"> = </span><span class="string-syntax">"past"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">m</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">HALF_HOUR</span><span class="plain-syntax">) { </span><span class="identifier-syntax">m</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">-</span><span class="identifier-syntax">m</span><span class="plain-syntax">; </span><span class="identifier-syntax">h</span><span class="plain-syntax"> = (</span><span class="identifier-syntax">h</span><span class="plain-syntax">+1)%12; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">h</span><span class="plain-syntax">==0) </span><span class="identifier-syntax">h</span><span class="plain-syntax">=12; </span><span class="identifier-syntax">dir</span><span class="plain-syntax"> = </span><span class="string-syntax">"to"</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><span class="identifier-syntax">m</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">QUARTER_HOUR</span><span class="plain-syntax">: </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"quarter"</span><span class="plain-syntax">; </span><span class="identifier-syntax">HALF_HOUR</span><span class="plain-syntax">: </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"half"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">default</span><span class="plain-syntax">: </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">m</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">m</span><span class="plain-syntax">%5 ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">m</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" minute"</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" minutes"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" "</span><span class="plain-syntax">, (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">dir</span><span class="plain-syntax">, </span><span class="string-syntax">" "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">number</span><span class="plain-syntax">) </span><span class="identifier-syntax">h</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Understanding.</b>This I6 grammar token converts words in the player's command to a valid
I7 time, and is heavily based on the one presented as a solution to an
exercise in the DM4.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TIME_TOKEN</span><span class="plain-syntax"> </span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">length</span><span class="plain-syntax"> </span><span class="identifier-syntax">flag</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">illegal_char</span><span class="plain-syntax"> </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">original_wn</span><span class="plain-syntax"> </span><span class="identifier-syntax">ch</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">original_wn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">wn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TIME_TOKEN_INNER</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">original_wn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first_word</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="character-syntax">'midnight'</span><span class="plain-syntax">: </span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">; </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_NUMBER</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="character-syntax">'midday'</span><span class="plain-syntax">, </span><span class="character-syntax">'noon'</span><span class="plain-syntax">: </span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TWELVE_HOURS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_NUMBER</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="comment-syntax">Next try the format 12:02</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">WordAddress</span><span class="plain-syntax">(</span><span class="identifier-syntax">wn</span><span class="plain-syntax">-1); </span><span class="identifier-syntax">length</span><span class="plain-syntax"> = </span><span class="identifier-syntax">WordLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">wn</span><span class="plain-syntax">-1);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">length</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">iftrue</span><span class="plain-syntax"> (</span><span class="identifier-syntax">CHARSIZE</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ch</span><span class="plain-syntax"> = </span><span class="identifier-syntax">at</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">Ifnot</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ch</span><span class="plain-syntax"> = </span><span class="identifier-syntax">at</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">Endif</span><span class="plain-syntax">; </span><span class="comment-syntax">CHARSIZE</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ch</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="character-syntax">':'</span><span class="plain-syntax">: </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flag</span><span class="plain-syntax"> == </span><span class="reserved-syntax">false</span><span class="plain-syntax"> &amp;&amp; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&gt;0 &amp;&amp; </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">length</span><span class="plain-syntax">-1) </span><span class="identifier-syntax">flag</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">illegal_char</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="character-syntax">'0'</span><span class="plain-syntax">, </span><span class="character-syntax">'1'</span><span class="plain-syntax">, </span><span class="character-syntax">'2'</span><span class="plain-syntax">, </span><span class="character-syntax">'3'</span><span class="plain-syntax">, </span><span class="character-syntax">'4'</span><span class="plain-syntax">, </span><span class="character-syntax">'5'</span><span class="plain-syntax">, </span><span class="character-syntax">'6'</span><span class="plain-syntax">, </span><span class="character-syntax">'7'</span><span class="plain-syntax">, </span><span class="character-syntax">'8'</span><span class="plain-syntax">, </span><span class="character-syntax">'9'</span><span class="plain-syntax">: ;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">default</span><span class="plain-syntax">: </span><span class="identifier-syntax">illegal_char</span><span class="plain-syntax"> = </span><span class="reserved-syntax">true</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">length</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">3</span><span class="plain-syntax"> || </span><span class="identifier-syntax">length</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">5</span><span class="plain-syntax"> || </span><span class="identifier-syntax">illegal_char</span><span class="plain-syntax">) </span><span class="identifier-syntax">flag</span><span class="plain-syntax"> = </span><span class="reserved-syntax">false</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flag</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">iftrue</span><span class="plain-syntax"> (</span><span class="identifier-syntax">CHARSIZE</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">at</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">~=</span><span class="character-syntax">':'</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++, </span><span class="identifier-syntax">hr</span><span class="plain-syntax">=</span><span class="identifier-syntax">hr</span><span class="plain-syntax">*10) </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> + </span><span class="identifier-syntax">at</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> - </span><span class="character-syntax">'0'</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">Ifnot</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax">~=</span><span class="character-syntax">':'</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++, </span><span class="identifier-syntax">hr</span><span class="plain-syntax">=</span><span class="identifier-syntax">hr</span><span class="plain-syntax">*10) </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> + </span><span class="identifier-syntax">at</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> - </span><span class="character-syntax">'0'</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">Endif</span><span class="plain-syntax">; </span><span class="comment-syntax">CHARSIZE</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hr</span><span class="plain-syntax">/10;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">iftrue</span><span class="plain-syntax"> (</span><span class="identifier-syntax">CHARSIZE</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">++: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">length</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++, </span><span class="identifier-syntax">mn</span><span class="plain-syntax">=</span><span class="identifier-syntax">mn</span><span class="plain-syntax">*10) </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> + </span><span class="identifier-syntax">at</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> - </span><span class="character-syntax">'0'</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">Ifnot</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">++: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">length</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++, </span><span class="identifier-syntax">mn</span><span class="plain-syntax">=</span><span class="identifier-syntax">mn</span><span class="plain-syntax">*10) </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> + </span><span class="identifier-syntax">at</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">i</span><span class="plain-syntax"> - </span><span class="character-syntax">'0'</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">Endif</span><span class="plain-syntax">; </span><span class="comment-syntax">CHARSIZE</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mn</span><span class="plain-syntax">/10;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HoursMinsWordToTime</span><span class="plain-syntax">(</span><span class="identifier-syntax">hr</span><span class="plain-syntax">, </span><span class="identifier-syntax">mn</span><span class="plain-syntax">, </span><span class="identifier-syntax">second_word</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> == -1) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> ~= </span><span class="character-syntax">'pm'</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="character-syntax">'am'</span><span class="plain-syntax">) </span><span class="identifier-syntax">wn</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_NUMBER</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="comment-syntax">Lastly the wordy format</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'half'</span><span class="plain-syntax">) </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HALF_HOUR</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'quarter'</span><span class="plain-syntax">) </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> = </span><span class="identifier-syntax">QUARTER_HOUR</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TryNumber</span><span class="plain-syntax">(</span><span class="identifier-syntax">wn</span><span class="plain-syntax">-1);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax"> || </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second_word</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">"six o'clock", "six"</span>
<span class="plain-syntax">        </span><span class="character-syntax">'o^clock'</span><span class="plain-syntax">, </span><span class="character-syntax">'am'</span><span class="plain-syntax">, </span><span class="character-syntax">'pm'</span><span class="plain-syntax">, -1:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">offhour</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">hr</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">12</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="comment-syntax">"quarter to six", "twenty past midnight"</span>
<span class="plain-syntax">        </span><span class="character-syntax">'to'</span><span class="plain-syntax">, </span><span class="character-syntax">'past'</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">offhour</span><span class="plain-syntax">; </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TryNumber</span><span class="plain-syntax">(</span><span class="identifier-syntax">wn</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">hr</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">()) {</span>
<span class="plain-syntax">                    </span><span class="character-syntax">'noon'</span><span class="plain-syntax">, </span><span class="character-syntax">'midday'</span><span class="plain-syntax">: </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> = </span><span class="constant-syntax">12</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="character-syntax">'midnight'</span><span class="plain-syntax">: </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">default</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">hr</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">13</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'to'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">-</span><span class="identifier-syntax">mn</span><span class="plain-syntax">; </span><span class="identifier-syntax">hr</span><span class="plain-syntax">--; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">hr</span><span class="plain-syntax">&lt;0) </span><span class="identifier-syntax">hr</span><span class="plain-syntax">=23;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">wn</span><span class="plain-syntax">++; </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="comment-syntax">"six thirty"</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">default</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">hr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">offhour</span><span class="plain-syntax">; </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TryNumber</span><span class="plain-syntax">(--</span><span class="identifier-syntax">wn</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mn</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax"> || </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">wn</span><span class="plain-syntax">++; </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HoursMinsWordToTime</span><span class="plain-syntax">(</span><span class="identifier-syntax">hr</span><span class="plain-syntax">, </span><span class="identifier-syntax">mn</span><span class="plain-syntax">, </span><span class="identifier-syntax">second_word</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> ~= </span><span class="character-syntax">'pm'</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="character-syntax">'am'</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="character-syntax">'o^clock'</span><span class="plain-syntax">) </span><span class="identifier-syntax">wn</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_NUMBER</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">HoursMinsWordToTime</span><span class="plain-syntax"> </span><span class="identifier-syntax">hour</span><span class="plain-syntax"> </span><span class="identifier-syntax">minute</span><span class="plain-syntax"> </span><span class="identifier-syntax">word</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">hour</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">24</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">minute</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hour</span><span class="plain-syntax">*</span><span class="identifier-syntax">ONE_HOUR</span><span class="plain-syntax"> + </span><span class="identifier-syntax">minute</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">hour</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">13</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">x</span><span class="plain-syntax"> % </span><span class="identifier-syntax">TWELVE_HOURS</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">word</span><span class="plain-syntax"> == </span><span class="character-syntax">'pm'</span><span class="plain-syntax">) </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">x</span><span class="plain-syntax"> + </span><span class="identifier-syntax">TWELVE_HOURS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">word</span><span class="plain-syntax"> ~= </span><span class="character-syntax">'am'</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="character-syntax">'pm'</span><span class="plain-syntax"> &amp;&amp; </span><span class="identifier-syntax">hour</span><span class="plain-syntax"> == </span><span class="constant-syntax">12</span><span class="plain-syntax">) </span><span class="identifier-syntax">x</span><span class="plain-syntax"> = </span><span class="identifier-syntax">x</span><span class="plain-syntax"> + </span><span class="identifier-syntax">TWELVE_HOURS</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">x</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Relative Time Token.</b>"Time" is an interesting kind of value since it can hold two conceptually
different ways of thinking about time: absolute times, such as "12:03 PM",
and also relative times, like "ten minutes". For parsing purposes, these
are completely different from each other, and the time token above handles
only absolute times; we need the following for relative ones.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATIVE_TIME_TOKEN</span><span class="plain-syntax"> </span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> </span><span class="identifier-syntax">mult</span><span class="plain-syntax"> </span><span class="identifier-syntax">mn</span><span class="plain-syntax"> </span><span class="identifier-syntax">original_wn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">original_wn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">wn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">original_wn</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">(); </span><span class="identifier-syntax">wn</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'an'</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="character-syntax">'a//'</span><span class="plain-syntax">) </span><span class="identifier-syntax">mn</span><span class="plain-syntax">=1; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">mn</span><span class="plain-syntax">=</span><span class="identifier-syntax">TryNumber</span><span class="plain-syntax">(</span><span class="identifier-syntax">wn</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mn</span><span class="plain-syntax"> == -1000) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'half'</span><span class="plain-syntax">) </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HALF_HOUR</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'quarter'</span><span class="plain-syntax">) </span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> = </span><span class="identifier-syntax">QUARTER_HOUR</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">offhour</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'of'</span><span class="plain-syntax">) </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'an'</span><span class="plain-syntax">) </span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">second_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'hour'</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> = </span><span class="identifier-syntax">offhour</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_NUMBER</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wn</span><span class="plain-syntax">++;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first_word</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="character-syntax">'minutes'</span><span class="plain-syntax">, </span><span class="character-syntax">'minute'</span><span class="plain-syntax">: </span><span class="identifier-syntax">mult</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="character-syntax">'hours'</span><span class="plain-syntax">, </span><span class="character-syntax">'hour'</span><span class="plain-syntax">: </span><span class="identifier-syntax">mult</span><span class="plain-syntax"> = </span><span class="constant-syntax">60</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">default</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_FAIL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> = </span><span class="identifier-syntax">mn</span><span class="plain-syntax">*</span><span class="identifier-syntax">mult</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mult</span><span class="plain-syntax"> == </span><span class="constant-syntax">60</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">mn</span><span class="plain-syntax">=</span><span class="identifier-syntax">TryNumber</span><span class="plain-syntax">(</span><span class="identifier-syntax">wn</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mn</span><span class="plain-syntax"> ~= -1000) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">wn</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NextWordStopped</span><span class="plain-syntax">();</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">first_word</span><span class="plain-syntax"> == </span><span class="character-syntax">'minutes'</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="character-syntax">'minute'</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> = </span><span class="identifier-syntax">parsed_number</span><span class="plain-syntax"> + </span><span class="identifier-syntax">mn</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">wn</span><span class="plain-syntax"> = </span><span class="identifier-syntax">wn</span><span class="plain-syntax"> - </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">GPR_NUMBER</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Scene Change Machinery Rule.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">SCENE_CHANGE_MACHINERY_R</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">DetectSceneChange</span><span class="plain-syntax">();</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. During Scene Matching.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">DuringSceneMatching</span><span class="plain-syntax"> </span><span class="identifier-syntax">prop</span><span class="plain-syntax"> </span><span class="identifier-syntax">sc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sc</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">sc</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">NUMBER_SCENES_CREATED</span><span class="plain-syntax">: </span><span class="identifier-syntax">sc</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">scene_status</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">sc</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">prop</span><span class="plain-syntax">(</span><span class="identifier-syntax">sc</span><span class="plain-syntax">+1))) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Scene Questions.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">SceneUtility</span><span class="plain-syntax"> </span><span class="identifier-syntax">sc</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sc</span><span class="plain-syntax"> &lt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">scene_endings</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">sc</span><span class="plain-syntax">-1) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"SceneHasNotStarted"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"The scene has not started."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** The scene in question is "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">PrintSceneName</span><span class="plain-syntax">) </span><span class="identifier-syntax">sc</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">scene_endings</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">sc</span><span class="plain-syntax">-1) &lt;= </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"SceneHasNotEnded"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"The scene has not ended."</span><span class="plain-syntax">, </span><span class="identifier-syntax">WorldModelKitRTPs</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** The scene in question is "</span><span class="plain-syntax">, (</span><span class="identifier-syntax">PrintSceneName</span><span class="plain-syntax">) </span><span class="identifier-syntax">sc</span><span class="plain-syntax">, </span><span class="string-syntax">".^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="constant-syntax">1</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TWENTY_FOUR_HOURS</span><span class="plain-syntax"> + </span><span class="identifier-syntax">the_time</span><span class="plain-syntax"> - </span><span class="identifier-syntax">scene_started</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">sc</span><span class="plain-syntax">-1))%(</span><span class="identifier-syntax">TWENTY_FOUR_HOURS</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="constant-syntax">2</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">scene_started</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">sc</span><span class="plain-syntax">-1);</span>
<span class="plain-syntax">        </span><span class="constant-syntax">3</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TWENTY_FOUR_HOURS</span><span class="plain-syntax"> + </span><span class="identifier-syntax">the_time</span><span class="plain-syntax"> - </span><span class="identifier-syntax">scene_ended</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">sc</span><span class="plain-syntax">-1))%(</span><span class="identifier-syntax">TWENTY_FOUR_HOURS</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="constant-syntax">4</span><span class="plain-syntax">: </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">scene_ended</span><span class="plain-syntax">--&gt;(</span><span class="identifier-syntax">sc</span><span class="plain-syntax">-1);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="mprtf.html">&#10094;</a></li><li class="progresssection"><a href="mscll.html">mscll</a></li><li class="progresssection"><a href="stt.html">stt</a></li><li class="progresssection"><a href="lght.html">lght</a></li><li class="progresssection"><a href="lstwr.html">lstwr</a></li><li class="progresssection"><a href="ordrf.html">ordrf</a></li><li class="progresssection"><a href="actns.html">actns</a></li><li class="progresssection"><a href="fgrs.html">fgrs</a></li><li class="progresssection"><a href="otfwr.html">otfwr</a></li><li class="progresssection"><a href="prntn.html">prntn</a></li><li class="progresssection"><a href="wrldm.html">wrldm</a></li><li class="progresssection"><a href="mprtf.html">mprtf</a></li><li class="progresscurrent">tm</li><li class="progresssection"><a href="tsts.html">tsts</a></li><li class="progresssection"><a href="chrnl.html">chrnl</a></li><li class="progresssection"><a href="strdc.html">strdc</a></li><li class="progressnext"><a href="tsts.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

